package com.example.controller;


import com.example.pojo.PageBean;
import com.example.pojo.Result;
import com.example.service.impl.NoticeServiceImpl;
import com.example.vd.vo.StatusVo;
import com.example.vd.vo.NoticeVo;
import jakarta.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 公告表 前端控制器
 * </p>
 *
 * @author fzy'
 * @since 2024-08-08
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/notice")
public class NoticeController {
    @Autowired
    private NoticeServiceImpl noticeService;
    @GetMapping("/list")
    public Result noticeList(@ModelAttribute PageBean pageBean,@Nullable @RequestParam String keyword){
        log.info("/list 参数: {},{}", pageBean,keyword);
        return noticeService.getNoticeList(pageBean,keyword);
    }

    @DeleteMapping("/delete")
    public Result deletedById(Long id) {
        log.info("/deleted 参数: {}", id);
        return noticeService.deletedById(id);
    }

    @PutMapping("/update")
    public Result updateByNotice(@RequestBody NoticeVo notice) {
        log.info("/update 参数: {}", notice);
        return noticeService.updateByNotice(notice);
    }


    @PostMapping("/insert")
    public Result insert(@RequestBody NoticeVo notice) {
        log.info("/insert 参数: {}", notice);
        return noticeService.insertByNotice(notice);
    }
}
